// @ts-ignore
/* eslint-disable */
import {request} from '@umijs/max';


/** 注册接口 POST /user/register */
export async function register(body: API.RegisterParams, options?: { [key: string]: any }) {
  return request<API.BaseResponse<number>>('/user/register', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}


/** 登录接口 POST /user/login */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
  return request<API.BaseResponse<API.CurrentUser>>('/user/login', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}


/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  return request<API.BaseResponse<number>>('/user/logout', {
    method: 'POST',
    ...(options || {}),
  });
}


/** 获取当前登录的用户信息 GET */
export async function currentUser() {
  return request<API.BaseResponse<API.CurrentUser>>('/user/currentLoginUser', {
    method: 'GET'
  });
}

// 获取所有用户
export async function getUserList(options?: any) {
  return request('/user/list', {
    method: 'GET',
    params: options
  });
}

// 修改当前用户信息
export async function updateUser(userId: string, body: any,) {
  return request<API.BaseResponse<number>>('/user/'+userId, {
    method: 'PATCH',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body
  });
}



// 头像上传
export async function uploadFile(file: File) {
  const formData = new FormData();
  formData.append('file', file);
  return request('/api/upload', {
    method: 'POST',
    data: formData,
  });
}